using Assets.Scripts.GDK;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class WelcomeRewardAlert : gdk_base_alert_layer
	{
		public RectTransform iconBg;

		private WelcomeConfigItemModel config;

		public RectTransform iconBox;

		public RectTransform coinMoveBoX;

		public Text valueText;

		public Button moveBtn;

		public Button addBtn1;

		public Button addBtn2;

		private int coinNum;

		public void OnData(int num, WelcomeConfigItemModel _config)
		{
			coinMoveBoX.gameObject.SetActive(value: false);
			config = _config;
			string id = ItemID.icon101Preafab;
			switch (config.ID)
			{
				case 101:
					id = ItemID.icon101Preafab;
					break;
				case 102:
					id = ItemID.icon102Preafab;
					break;
				case 103:
					id = ItemID.icon103Preafab;
					break;
				case 104:
					id = ItemID.icon104Preafab;
					break;
			}
			GameObject gameObject = gdk_game_manager.loadPrefab(id);
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.SetParent(iconBox);
			component.localPosition = new Vector2(0f, 0f);
			component.localScale = new Vector3(1f, 1f, 1f);
			if (config.ID == 104)
			{
				string arg = "x";
				string[] array = gdk_utils.Split(config.other, ",");
				int minNum = gdk_stringPlus.string2int(array[0]);
				int maxNum = gdk_stringPlus.string2int(array[1]);
				coinNum = gdk_utils.Random(minNum, maxNum);
				arg += coinNum;
				valueText.text = arg;
			}
			else
			{
				string text = "x" + config.num;
				valueText.text = text;
			}
			if (num == 0)
			{
				moveBtn.gameObject.SetActive(value: true);
				addBtn1.gameObject.SetActive(value: true);
			}
			else
			{
				addBtn2.gameObject.SetActive(value: true);
			}
		}

		public override void OnLoad()
		{
		}

		public override void OnUpdate()
		{
			iconBg.Rotate(0f, 0f, Time.deltaTime * 50f);
		}

		private void hideBtns()
		{
			moveBtn.gameObject.SetActive(value: false);
			addBtn1.gameObject.SetActive(value: false);
			addBtn2.gameObject.SetActive(value: false);
		}

		public void OnMoreBtnClick()
		{
			hideBtns();
			GameManager.PlayAdvert("10003", "4", delegate
			{
				addReward(delegate
				{
					close();
				});
			}, delegate
			{
				addReward(delegate
				{
					close();
				});
			});
		}

		public void OnBtnClick()
		{
			hideBtns();
			addReward(delegate
			{
				close();
			});
		}

		private void addReward(Action closeCallback)
		{
		}
	}
}

